package org.cmind.soap.android;

import java.util.ArrayList;
import java.util.List;

/**
 * Base for other objects. 
 * @author marcin
 *
 */
abstract class BasicSoapObject implements SoapObject {

    private List<Attribute> attrs = new ArrayList<Attribute>();
    protected String name;
    protected String namespace;

    @Override
    public List<Attribute> getAttributes() {

        return attrs;
    }

    BasicSoapObject(String name, String namespace) {
        this.name = name;
        this.namespace = namespace;
    }

    BasicSoapObject(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getNamespace() {
        return namespace;
    }

    @Override
    public abstract String getValue();

    @Override
    public void setNamespace(String namespace) {
        this.namespace = namespace;

    }

    @Override
    public boolean addAttribute(Attribute attr) {

        return attrs.add(attr);
    }

    @Override
    public boolean removeAttribute(Attribute attr) {

        return attrs.remove(attr);
    }
    
    @Override
    public void setAttributes(List<Attribute> attrs){
        this.attrs = attrs;
    }

}
